<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>职业发展</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/myDevelop.css" />
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>我的测评</h3>
  </div>
  <div id="all">
    <div class="MyTest">
      <div class="item">
          <div class="left">
            <div class="title">性格测评</div>
          </div>
          <div class="right">
            <div class="content">
              <span class="status"></span>
              <span class="time"></span>
            </div>
            <div class="tools"><button class="btn btn-info"  tapmode>测试结果</button></div>
          </div>
      </div>
      <div class="item">
          <div class="left">
            <div class="title">岗位倾向测评</div>
          </div>
          <div class="right">
            <div class="content">
              <span class="status"></span>
              <span class="time"></span>
            </div>
            <div class="tools"><button class="btn btn-info" tapmode>测试结果</button></div>
          </div>
      </div>
      <div class="item">
          <div class="left">
            <div class="title">岗位能力测评</div>
          </div>
          <div class="right">
            <div class="content">
              <span class="status"></span>
              <span class="time"></span>
            </div>
            <div class="tools"><button class="btn btn-info" tapmode>测试结果</button></div>
          </div>
      </div>
      <div class="item">
          <div class="left">
            <div class="title">综合测评</div>
          </div>
          <div class="right">
            <div class="content">
              <span class="status"></span>
              <span class="time"></span>
            </div>
            <div class="tools"><button class="btn btn-info" tapmode>测试结果</button></div>
          </div>
      </div>
    </div>
  </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
apiready=function(){
  var flag=$api.getStorage('flag');
  var aid=$api.getStorage('aid');
  var jwt=$api.getStorage('jwt');
  var personinfo,personality,jobsTendency,jobsAbility,comprehensive;
  //获取测评成绩
  api.ajax({
    url: 'http://47.104.170.122/v1/portal/evaluating/stuinfo/stupersoninfo/?token='+jwt,
    method: 'GET',
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Headers": "Authorization",
      "Content-Type" : 'application/json; charset=utf-8'
    }
  }, function(ret, err) {
      if (ret.code==0) {
        var data=ret.data;
        personality=JSON.parse(data.personality);
        jobsTendency=JSON.parse(data.jobsTendency);
        jobsAbility=JSON.parse(data.jobsAbility);
        comprehensive=JSON.parse(data.comprehensive);
        personName=data.personinfo.name;
        if(data.personality.indexOf("[")==0){
          personality=personality[0];
        }
        if(data.jobsTendency.indexOf("[")==0){
          jobsTendency=jobsTendency[0];
        }
        if(data.jobsAbility.indexOf("[")==0){
          jobsAbility=jobsAbility[0];
        }
        if(data.comprehensive.indexOf("[")==0){
          comprehensive=comprehensive[0];
        }
        if(personality==null){
          $(".MyTest .item").eq(0).find(".status").text('未测试');
          $(".MyTest .item").eq(0).find(".tools").addClass("hide");
          $(".MyTest .item").eq(0).find(".status").addClass("doing");
        }else{
          $(".MyTest .item").eq(0).find(".status").text('已完成');
          $(".MyTest .item").eq(0).find(".time").text((personality.submittime).replace(/T/g," ").substring(0,personality.submittime.length-14));
          $(".MyTest .item").eq(0).find(".status").addClass("finished");
        }
        if(jobsTendency==null){
          $(".MyTest .item").eq(1).find(".status").text('未测试');
          $(".MyTest .item").eq(1).find(".tools").addClass("hide");
          $(".MyTest .item").eq(1).find(".status").addClass("doing");
        }else{
          $(".MyTest .item").eq(1).find(".status").text('已完成');
          $(".MyTest .item").eq(1).find(".status").addClass("finished");
          $(".MyTest .item").eq(1).find(".time").text((jobsTendency.submittime).replace(/T/g," ").substring(0,jobsTendency.submittime.length-14));
        }
        if(jobsAbility==null){
          $(".MyTest .item").eq(2).find(".status").text('未测试');
          $(".MyTest .item").eq(2).find(".tools").addClass("hide");
          $(".MyTest .item").eq(2).find(".status").addClass("doing");
        }else{
          $(".MyTest .item").eq(2).find(".status").text('已完成');
          $(".MyTest .item").eq(2).find(".status").addClass("finished");
          $(".MyTest .item").eq(2).find(".time").text((jobsAbility.submittime).replace(/T/g," ").substring(0,jobsAbility.submittime.length-14));
        }
        if(comprehensive==null){
          $(".MyTest .item").eq(3).find(".status").text('未测试');
          $(".MyTest .item").eq(3).find(".tools").addClass("hide");
          $(".MyTest .item").eq(3).find(".status").addClass("doing");
        }else{
          $(".MyTest .item").eq(3).find(".status").text('已完成');
          $(".MyTest .item").eq(3).find(".status").addClass("finished");
          $(".MyTest .item").eq(3).find(".time").text((comprehensive.applicationTime).replace(/T/g," ").substring(0,comprehensive.applicationTime.length-14));
        }
      } else {
        toast("获取测评结果失败","middle");
      }
  });
  $(".MyTest .tools .btn").click(function(){
    var index=$(this).closest(".item").index();
    api.openWin({
       name: 'result',
       url: 'result.html',
       pageParam: {
           index:index,
           personality:personality,
           jobsTendency:jobsTendency,
           jobsAbility:jobsAbility,
           comprehensive:comprehensive,
           personName:personName
       }
   });
  })
}
//jquery
$(function(){
  back();
  $(".tabs span").on("touchstart",function(){
    $(this).addClass("active").siblings().removeClass("active");
    $(".MyTest .item").eq($(this).index()).addClass("active").siblings().removeClass("active");
  });
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
